<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //同时刻onload事件只能触发一次
        window.onload=function(){
            console.log('张三写的代码')
        };

        window.onload=function(){
            console.log('李四写的代码')
        }
    </script>
</head>
<body>
    <button>按钮</button>
</body>
</html>
<script>
    //使用事件监听解决这个问题
    let btn=document.querySelector('button');
    btn.addEventListener('click',function(){
        console.log('张三的代码');
    })
    btn.addEventListener('click',function(){
        console.log('李四的代码');
    })
</script>